package com.pocketsweet.ui.uilib;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.pocketsweet.R;
import com.pocketsweet.service.UserService;

public class ApplyChatView extends LinearLayout {
	private ImageView myImage;
	private ImageView toImage;

	public ApplyChatView(Context context) {
		super(context);
		// 初始化
		init(context);
	}

	public ApplyChatView(Context context, AttributeSet attrs) {
		super(context, attrs);

		// 初始化
		init(context);
	}

	private void init(Context context) {
		View root = inflate(context, R.layout.view_apply_chat, null);
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		addView(root, params);
		myImage = (ImageView) root.findViewById(R.id.myImage);
		toImage = (ImageView) root.findViewById(R.id.toImage);
		UserService.displaySquare(UserService.getCurrentUser().getAvatarUrl(), myImage);
		myImage.setTag(myImage);
	}

	public void setToImage(String avatar) {
		if (avatar != null && !avatar.equals("")) {
			UserService.displaySquare(avatar, toImage);
			toImage.setTag(avatar);
		} else {
			toImage.setImageResource(R.drawable.default_user_avatar);
		}
	}
	
}
